package com.dongjiantong.quarantine.serviceImpl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongjiantong.mybatis.ServiceMybatis;
import com.dongjiantong.quarantine.mapper.HarmlessMapper;
import com.dongjiantong.quarantine.model.Harmless;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Created by mz on 23/11/17.
 *
 */
@Slf4j
@Service(version = "1.0.0")
public class HarmlessReadServiceImpl extends ServiceMybatis<Harmless> implements HarmlessReadService{

    @Resource
    private HarmlessMapper harmlessMapper;

    /**
     * 查询单据详情
     *
     * @param id 主键id
     * @return Harmless
     */
    @Override
    public Harmless findById(Long id) {
        return harmlessMapper.selectByPrimaryKey(id);
    }

    /**
     * 获取但钱单据状态
     *
     * @param id 单据主键id
     * @return Integer status
     */
    @Override
    public Integer findStatusById(Long id) {
        return harmlessMapper.findStatusById(id);
    }

    /**
     * 养殖端的分页查询
     *
     * @param pageNo   页码
     * @param pageSize 条数
     * @param map      参数
     * @return PageInfo<Harmless>
     */
    @Override
    public PageInfo<Harmless> pagingForFarm(Integer pageNo, Integer pageSize, Map<String, Object> map) {
        PageHelper.startPage(pageNo, pageSize);

        List<Harmless> harmlessList = harmlessMapper.pagingForFarm(map);

        PageInfo<Harmless> harmlessPageInfo = new PageInfo<>(harmlessList);
        return harmlessPageInfo;
    }

    /**
     * 屠宰端的分页查询
     *
     * @param pageNo   页码
     * @param pageSize 条数
     * @param map      参数
     * @return PageInfo<Harmless>
     */
    @Override
    public PageInfo<Harmless> pagingForButcher(Integer pageNo, Integer pageSize, Map<String, Object> map) {
        PageHelper.startPage(pageNo, pageSize);
        List<Harmless> harmlessList = harmlessMapper.pagingForButcher(map);
        PageInfo<Harmless> harmlessPageInfo = new PageInfo<>(harmlessList);
        return harmlessPageInfo;
    }

    /**
     * 政府端的分页查询
     *
     * @param pageNo   页码
     * @param pageSize 条数
     * @param map      参数
     * @return PageInfo<Harmless>
     */
    @Override
    public PageInfo<Harmless> pagingForGov(Integer pageNo, Integer pageSize, Map<String, Object> map) {
        PageHelper.startPage(pageNo, pageSize);
        List<Harmless> harmlessList = harmlessMapper.pagingForGov(map);
        PageInfo<Harmless> harmlessPageInfo = new PageInfo<>(harmlessList);
        return harmlessPageInfo;
    }

    @Override
    public List<Map<String, Object>> findAWeekSumIsLocal(Map<String, Object> map) {
        return harmlessMapper.findAWeekSumIsLocal(map);
    }

    @Override
    public List<Map<String, Object>> findAWeekSumReportType(Map<String, Object> map) {
        return harmlessMapper.findAWeekSumReportType(map);
    }

    @Override
    public List<Map<String, Object>> getAWeekHarmlessByTreatment(Map<String, Object> paramsMap) {
        return harmlessMapper.getAWeekHarmlessByTreatment(paramsMap);
    }
}
